package com.ipan.weixin.msg.send;

import com.ipan.weixin.msg.general.XmlMsg;

/**
 * 发送图片消息
 * 
 * @author iPan
 * @version 2013-12-25
 */
public class ImageSendMsg extends AbstractSendJsonMsg {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 7745679571233600925L;

	private Image image;
	
	public ImageSendMsg() {
		super(XmlMsg.TYPE_IMAGE);
	}
	
	public ImageSendMsg(String touser) {
		super(touser, XmlMsg.TYPE_IMAGE);
	}
	
	public ImageSendMsg(String touser, String mediaId) {
		super(touser, XmlMsg.TYPE_IMAGE);
		setImage(mediaId);
	}
	
	public Image getImage() {
		return image;
	}

	public void setImage(Image image) {
		this.image = image;
	}
	
	public void setImage(String mediaId) {
		this.image = new Image(mediaId);
	}
	
	public String mediaId() {
		return (image != null) ? image.getMedia_id() : null;
	}

	class Image {
		
		private String media_id;
		
		public Image() {}

		public Image(String media_id) {
			this.media_id = media_id;
		}

		public String getMedia_id() {
			return media_id;
		}

		public void setMedia_id(String media_id) {
			this.media_id = media_id;
		}
		
	}
	
//	public static void main(String[] args) {
//		ImageServiceMsg msg = new ImageServiceMsg("OPENID", "MEDIA_ID");
//		System.out.println(msg);
//	}

}

/*
发送：
{
    "touser":"OPENID",
    "msgtype":"image",
    "image":
    {
      "media_id":"MEDIA_ID"
    }
}
*/
